package com.bountytask.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.bountytask.dao.UserDao;
import com.bountytask.entity.UserInfo;
import com.bountytask.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;

    //更新用户信息
    public JSONObject updateUserInfo(UserInfo user){
        JSONObject resultJson = new JSONObject(true);
        if (userDao.updateUserInfo(user)!=1){
            resultJson.put("code",400);
            resultJson.put("message","失败");
            return resultJson;
        }
        resultJson.put("code",200);
        resultJson.put("message","成功");
        return resultJson;
    }

    //根据id获取用户
    public UserInfo getUserById(long id){
        return userDao.getUserById(id);
    }
}
